<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
        <html><head>
        <link rel="stylesheet" type="text/css" href="apidocs.css"/>
        <title>API docs for &ldquo;sympy.functions.combinatorial.factorials.Binomial&rdquo;</title>
        </head>
        <body><h1 class="class">Class s.f.c.f.Binomial(<a href="sympy.core.function.Function.html">Function</a>):</h1><span id="part">Part of <a href="sympy.functions.combinatorial.factorials.html">sympy.functions.combinatorial.factorials</a></span><div class="toplevel"><pre>Implementation of the binomial coefficient. It can be defined
in two ways depending on its desired interpretation:

    C(n,k) = n!/(k!(n-k)!)   or   C(n, k) = ff(n, k)/k!

First formula has strict combinatorial meaning, definig the
number of ways we can choose 'k' elements from 'n' element
set. In this case both arguments are nonnegative integers
and binomial is computed using efficient algorithm based
on prime factorisation.

The other definition is generalisation for arbitaty 'n',
however 'k' must be also nonnegative. This case is very
useful in case for evaluating summations.

For the sake of convenience for negative 'k' this function
will return zero no matter what valued is the other argument.

>>> from sympy import *
>>> n = symbols('n', integer=True)

>>> binomial(15, 8)
6435

>>> binomial(n, -1)
0

>>> [ binomial(0, i) for i in range(1)]
[1]
>>> [ binomial(1, i) for i in range(2)]
[1, 1]
>>> [ binomial(2, i) for i in range(3)]
[1, 2, 1]
>>> [ binomial(3, i) for i in range(4)]
[1, 3, 3, 1]
>>> [ binomial(4, i) for i in range(5)]
[1, 4, 6, 4, 1]

>>> binomial(Rational(5,4), 3)
-5/128

>>> binomial(n, 3)
(1/6)*n*(-1 + n)*(-2 + n)</pre></div><table class="children"><tr class="function"><td>Function</td><td><a href="#sympy.functions.combinatorial.factorials.Binomial.canonize">canonize</a></td><td><div><p>Returns a canonical form of cls applied to arguments args.</p>
</div></td></tr><tr class="function"><td>Function</td><td><a href="#sympy.functions.combinatorial.factorials.Binomial._eval_rewrite_as_gamma">_eval_rewrite_as_gamma</a></td><td><span class="undocumented">Undocumented</span></td></tr><tr class="function"><td>Function</td><td><a href="#sympy.functions.combinatorial.factorials.Binomial._eval_is_integer">_eval_is_integer</a></td><td><span class="undocumented">Undocumented</span></td></tr></table>
            <div class="function">
            <div class="functionHeader">def <a name="sympy.functions.combinatorial.factorials.Binomial.canonize">canonize(cls, r, k):</a></div>
            <div class="functionBody"><pre>Returns a canonical form of cls applied to arguments args.

The canonize() method is called when the class cls is about to be
instantiated and it should return either some simplified instance
(possible of some other class), or if the class cls should be
unmodified, return None.

Example of canonize() for the function "sign"
---------------------------------------------

@classmethod
def canonize(cls, arg):
    if arg is S.NaN:
        return S.NaN
    if arg is S.Zero: return S.One
    if arg.is_positive: return S.One
    if arg.is_negative: return S.NegativeOne
    if isinstance(arg, C.Mul):
        coeff, terms = arg.as_coeff_terms()
        if coeff is not S.One:
            return cls(coeff) * cls(C.Mul(*terms))</pre></div>
            </div>
            <div class="function">
            <div class="functionHeader">def <a name="sympy.functions.combinatorial.factorials.Binomial._eval_rewrite_as_gamma">_eval_rewrite_as_gamma(self, r, k):</a></div>
            <div class="functionBody"><div class="undocumented">Undocumented</div></div>
            </div>
            <div class="function">
            <div class="functionHeader">def <a name="sympy.functions.combinatorial.factorials.Binomial._eval_is_integer">_eval_is_integer(self):</a></div>
            <div class="functionBody"><div class="undocumented">Undocumented</div></div>
            </div></body>
        